#include"Renderer.h"
//#include"mgepch.h"
#include"RenderCommand.h"

#include"myMiniEngine/Platform/OpenGL/OpenGLShader.h"

namespace myMiniEngine {	
	Renderer::SceneData* Renderer::sceneData = new Renderer::SceneData;

	void Renderer::Init() {
		RenderCommand::Init();
	}


	void Renderer::BeginScene(OrthographicCamera& camera)
	{
		sceneData->ViewProjectionMatrix = camera.GetViewProjectionMatrix();
	}

	void Renderer::EndScene() {

	}

	void Renderer::Submit(const Ref<Shader>& shader, const Ref<VertexArray>& vertexArray, const glm::mat4& transform)
	{
		shader->Bind();
		std::dynamic_pointer_cast<OpenGLShader>(shader)->UploadUniformMat4("u_ViewProjection", sceneData->ViewProjectionMatrix);
		std::dynamic_pointer_cast<OpenGLShader>(shader)->UploadUniformMat4("u_Transform", transform);

		vertexArray->Bind();
		RenderCommand::DrawIndexed(vertexArray);
	}
	
}